/*
 * The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use
 * this file except in compliance with the License. You can obtain a copy of the license at glassfish/bootstrap/legal/CDDLv1.0.txt or
 * https://glassfish.dev.java.net/public/CDDLv1.0.html. See the License for the specific language governing permissions and limitations
 * under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at
 * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets
 * "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] Copyright 2005 Sun Microsystems,
 * Inc. All rights reserved. Portions Copyright Apache Software Foundation.
 */

package jmine.tec.web.servlet.delegate;

import java.io.IOException;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

/**
 * Provides a convenient implementation of the HttpServletResponse interface that can be subclassed by developers wishing to adapt the
 * response from a Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped
 * response object.
 * 
 * @author Various
 * @since v 2.3
 * @see javax.servlet.http.HttpServletResponse
 */

public class HttpServletResponseWrapper extends ServletResponseWrapper implements HttpServletResponse {

    /**
     * Constructs a response adaptor wrapping the given response.
     * 
     * @param response the delegating response
     */
    public HttpServletResponseWrapper(HttpServletResponse response) {
        super(response);
    }

    /**
     * @return the delegate
     */
    private HttpServletResponse getHttpServletResponse() {
        return (HttpServletResponse) super.getResponse();
    }

    /**
     * {@inheritDoc}
     */
    public void addCookie(Cookie cookie) {
        this.getHttpServletResponse().addCookie(cookie);
    }

    /**
     * {@inheritDoc}
     */
    public boolean containsHeader(String name) {
        return this.getHttpServletResponse().containsHeader(name);
    }

    /**
     * {@inheritDoc}
     */
    public String encodeURL(String url) {
        return this.getHttpServletResponse().encodeURL(url);
    }

    /**
     * {@inheritDoc}
     */
    public String encodeRedirectURL(String url) {
        return this.getHttpServletResponse().encodeRedirectURL(url);
    }

    /**
     * {@inheritDoc}
     * 
     * @deprecated
     */
    public String encodeUrl(String url) {
        return this.getHttpServletResponse().encodeUrl(url);
    }

    /**
     * {@inheritDoc}
     * 
     * @deprecated
     */
    public String encodeRedirectUrl(String url) {
        return this.getHttpServletResponse().encodeRedirectUrl(url);
    }

    /**
     * {@inheritDoc}
     */
    public void sendError(int sc, String msg) throws IOException {
        this.getHttpServletResponse().sendError(sc, msg);
    }

    /**
     * {@inheritDoc}
     */
    public void sendError(int sc) throws IOException {
        this.getHttpServletResponse().sendError(sc);
    }

    /**
     * {@inheritDoc}
     */
    public void sendRedirect(String location) throws IOException {
        this.getHttpServletResponse().sendRedirect(location);
    }

    /**
     * {@inheritDoc}
     */
    public void setDateHeader(String name, long date) {
        this.getHttpServletResponse().setDateHeader(name, date);
    }

    /**
     * {@inheritDoc}
     */
    public void addDateHeader(String name, long date) {
        this.getHttpServletResponse().addDateHeader(name, date);
    }

    /**
     * {@inheritDoc}
     */
    public void setHeader(String name, String value) {
        this.getHttpServletResponse().setHeader(name, value);
    }

    /**
     * {@inheritDoc}
     */
    public void addHeader(String name, String value) {
        this.getHttpServletResponse().addHeader(name, value);
    }

    /**
     * {@inheritDoc}
     */
    public void setIntHeader(String name, int value) {
        this.getHttpServletResponse().setIntHeader(name, value);
    }

    /**
     * {@inheritDoc}
     */
    public void addIntHeader(String name, int value) {
        this.getHttpServletResponse().addIntHeader(name, value);
    }

    /**
     * {@inheritDoc}
     */
    public void setStatus(int sc) {
        this.getHttpServletResponse().setStatus(sc);
    }

    /**
     * {@inheritDoc}
     * 
     * @deprecated
     */
    public void setStatus(int sc, String sm) {
        this.getHttpServletResponse().setStatus(sc, sm);
    }

}
